
 --SELECT * FROM UV_CCONDTRPCEE
-- SELECT * FROM erp_mli2.cee_condtrp


--POUR CONTROLE


define erp='erp_mli2.';
define outils='outils_mli2.';

drop table se_cee_condtrp;
CREATE TABLE se_cee_condtrp AS (SELECT * FROM &erp.cee_condtrp WHERE 1=2);




 -- select * from uv_pfamilles order by ID
 -- select * from se_ART_FAM
 -- select * from &erp.ART_FAM



 INSERT INTO se_cee_condtrp
 (SELECT   id condtrp_cod,
           0 enreg_id,
           'N' enreg_s,
           libelle condtrp_lib,
           NULL condtrp_lib2
    FROM UV_CCONDTRPCEE) ;

 UPDATE se_cee_condtrp tf SET enreg_id=(select enreg_id FROM &erp.cee_condtrp f WHERE f.condtrp_cod=tf.condtrp_cod) ;
 UPDATE se_cee_condtrp tf SET enreg_id=&outils.enreg_id.NEXTVAL WHERE enreg_id IS NULL OR enreg_id =0;



 CALL uvse_synchroverserp('condtrp_cod','CEE_CONDTRP','O') ;

 commit;
 
 
select * from (
SELECT &outils.stragg(source) source,condtrp_cod, enreg_id, enreg_s, condtrp_lib, condtrp_lib2
FROM (
  SELECT 'uv' source ,g.* FROM se_cee_condtrp g
  UNION ALL
  SELECT 'se' source ,g.* FROM &erp.cee_condtrp g
  )
GROUP BY condtrp_cod, enreg_id, enreg_s, condtrp_lib, condtrp_lib2
HAVING Count(1)!=2) r
ORDER BY condtrp_cod